package com.jblv.frame.config.event;

import java.util.Properties;

/**
 * @author happyonion.yangtao
 * @version 1.0
 * @title LoggerLevelConfigChangeEventListener
 * @projectName jblv-frame
 * @packageName com.jblv.frame.config.event
 * @description TODO
 * @date Create at 2020/9/7 17:48
 * @since jdk1.8
 */

public class LoggerLevelConfigChangeEventListener implements ConfigChangeEventListener
{
    private final String LOGGER_LEVEL_KEY = "logger.out.level";

    @Override
    public boolean isSupport(final ConfigChangeEvent event) {
        final Properties change = event.getChange();
        return change.get("logger.out.level") != null;
    }

    @Override
    public void execute(final ConfigChangeEvent event) {
         Properties change = event.getChange();
         //LoggerAdapterSetter setter = LoggerAdapterFactory.getSetter();
         String level = change.getProperty("logger.out.level", "INFO");
         //setter.setLoggerLevel(LoggerLevelEnum.get(level));  //动态修改日志级别
    }

    public void afterPropertiesSet() throws Exception {
        ConfigChangeEventBus.build().register(this);
    }
}